package com.sc.eurekaclient.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

/**
 * @auther sc
 * @Date 2017/10/27
 */
@RestController
public class HiController {

    @Value("${server.port}")
    String port;

    @RequestMapping("/hi")
    public String home(@RequestParam String name)  {
        //Thread.sleep(5000);
        return "hi "+name+",i am from port:" +port;
    }


    @GetMapping("/user/{id}")
    public User getUser(@PathVariable("id")Integer id){
        User user = new User();
        user.setId(id);
        user.setName("sc");
        return user;
    }

    @GetMapping("/hh")
    public String hh(String name){
//        try {
//            Thread.sleep(50000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        return name;
    }

}
